package com.atguigu.hellomp.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * @BelongsProject: lease
 * @BelongsPackage: com.atguigu.hellomp.handler
 * @Author: jiangyi
 * @CreateTime: 2025-08-13  20:43
 * @Description: TODO
 * @Version: 1.0
 */
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {

    // 自动填充创建时间、修改时间处理器
    @Override
    public void insertFill(MetaObject metaObject) {
        // 创建时间
        this.strictInsertFill(metaObject,"createTime", LocalDateTime.class,LocalDateTime.now());
        this.strictInsertFill(metaObject,"updateTime", LocalDateTime.class,LocalDateTime.now());
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        // 修改时间
        this.strictUpdateFill(metaObject,"updateTime", LocalDateTime.class,LocalDateTime.now());
    }
}
